<?php

/**
 * This is the model class for table "asistencias".
 *
 * The followings are the available columns in table 'asistencias':
 * @property integer $id
 * @property string $hora_ingreso
 * @property string $hora_salida
 * @property string $hora_ireceso
 * @property string $hora_ereceso
 * @property string $fecha
 * @property string $EMPLEADOS_dni
 *
 * The followings are the available model relations:
 * @property Empleados $eMPLEADOSDni
 */
class Asistencias extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Asistencias the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'asistencias';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('hora_ingreso, hora_salida, fecha, EMPLEADOS_dni', 'required'),
			array('EMPLEADOS_dni', 'length', 'max'=>45),
			array('hora_ireceso, hora_ereceso', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, hora_ingreso, hora_salida, hora_ireceso, hora_ereceso, fecha, EMPLEADOS_dni', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'eMPLEADOSDni' => array(self::BELONGS_TO, 'Empleados', 'EMPLEADOS_dni'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'hora_ingreso' => 'Hora Ingreso',
			'hora_salida' => 'Hora Salida',
			'hora_ireceso' => 'Hora Ireceso',
			'hora_ereceso' => 'Hora Ereceso',
			'fecha' => 'Fecha',
			'EMPLEADOS_dni' => 'Empleados Dni',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('hora_ingreso',$this->hora_ingreso,true);
		$criteria->compare('hora_salida',$this->hora_salida,true);
		$criteria->compare('hora_ireceso',$this->hora_ireceso,true);
		$criteria->compare('hora_ereceso',$this->hora_ereceso,true);
		$criteria->compare('fecha',$this->fecha,true);
		$criteria->compare('EMPLEADOS_dni',$this->EMPLEADOS_dni,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}